package com.xoa.controller.document;

import com.xoa.model.document.DocumentExchangeOutUnit;
import com.xoa.service.document.DocumentExchangeOutUnitService;
import com.xoa.util.ToJson;
import com.xoa.util.page.PageParams;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/DocumentExchangeOutUnit")
public class DocumentExchangeOutUnitController {
    @Resource
    DocumentExchangeOutUnitService documentExchangeOutUnitService;
    //新增
    @RequestMapping("/insert")
    @ResponseBody
    public ToJson insert(DocumentExchangeOutUnit documentExchangeOutUnit){
        return documentExchangeOutUnitService.insert(documentExchangeOutUnit);
    }
    //更新
    @RequestMapping("/update")
    @ResponseBody
    public ToJson update(DocumentExchangeOutUnit documentExchangeOutUnit){
        return documentExchangeOutUnitService.update(documentExchangeOutUnit);
    }
    //查询
    @RequestMapping("/query")
    @ResponseBody
    public ToJson<DocumentExchangeOutUnit> query(PageParams pageParams,Integer limit, DocumentExchangeOutUnit documentExchangeOutUnit){
        Map<String, Object> map = new HashMap<>();
        pageParams.setPageSize(limit);
        map.put("page",pageParams);
        map.put("obj",documentExchangeOutUnit);
       return documentExchangeOutUnitService.query(map);
    }
    //删除
    @RequestMapping("/delete")
    @ResponseBody
    public ToJson delete(Integer ouId){
        return documentExchangeOutUnitService.delete(ouId);
    }

}
